
# assume * to be the wild char  -- therefore the match string don't have the *
# also assume that there's no two consecutive * chars
def is_wild_match(s,p):
    i = j = 0
    while(i < len(s) and j < len(p)):
        if(s[i] == p[j]):
            i += 1; j+= 1
        elif(p[j] == '*' and (is_wild_match(s[i+1:],p[j:]) or is_wild_match(s[i:],p[j+1:]))):
            return True
        else:
            i += 1

    return j >= len(p)



a = "cabccbabcaab"
p = "ab*ba*c"

print is_wild_match(a,p)
